﻿@{
    ViewBag.Title = "title";
}
@Html.Partial("Head")
<h2>title</h2>

<input type="button" name="name" value="2014-10-16T17:41:30" onclick="fun1()" />
<input type="button" name="name" value=" " onclick="fun1()" />
<input type="button" name="name" value=" " onclick="fun1()" />
<input type="button" name="name" value=" " onclick="fun1()" />

<script>
    //oracle的时间字符串为 2014-10-16T17:41:30  有的浏览器能识别 有的不能.
    function DateStrToDate(dateStr) {
        var str = dateStr.replace("T", " ");
        var date = new Date(str);
        if (date > (new Date("1990-01-01"))) {
            return date;
        } else {
            return new Date(dateStr);
        }
    }

    Date.prototype.format = function (format) {
        var o = {
            "M+": this.getMonth() + 1, //month
            "d+": this.getDate(), //day
            "h+": this.getHours(), //hour
            "m+": this.getMinutes(), //minute
            "s+": this.getSeconds(), //second
            "q+": Math.floor((this.getMonth() + 3) / 3), //quarter
            "S": this.getMilliseconds() //millisecond
        };
        if (/(y+)/.test(format))
            format = format.replace(RegExp.$1,
            (this.getFullYear() + "").substr(4 - RegExp.$1.length));
        for (var k in o)
            if (new RegExp("(" + k + ")").test(format))
                format = format.replace(RegExp.$1,
                    RegExp.$1.length == 1 ? o[k] :
                    ("00" + o[k]).substr(("" + o[k]).length));
        return format;


    };
    function fun1() {
        var str = $("input:first").val();
        var date = DateStrToDate(str);
        console.log(date.format("yyyy-MM-dd hh:mm"));
    }

</script>